package com.been.common.page;

/**
 * 分页信息
 * 
 * @author zhubin 2011-09-29
 */
public class PageInfo {

	/**
	 * 总页数
	 */
	private int totalPage = 1;

	/**
	 * 上一页
	 */
	private int prevPage = 1;

	/**
	 * 下一页
	 */
	private int nextPage = 1;

	/**
	 * 总记录
	 */
	private int totalRec = 0;

	/**
	 * 默认每页的记录数
	 */
	private final int defaultPageSize = 10;

	/**
	 * 每页的记录数
	 */
	private int pageSize = defaultPageSize;

	/**
	 * 当前页
	 */
	private int pageIndex = 1;

	/**
	 * 页码
	 */
	private int[] pageNumbers;

	/**
	 * 是否有上一页
	 */
	private boolean hasPrevPage = false;

	/**
	 * 是否有下一页
	 */
	private boolean hasNextPage = false;
	
	/**
	 * 是否显示分页信息
	 * 当查询的数据为空时不显示分页信息
	 */
	private boolean hasPageInfo = true;

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage > 0 ? totalPage : 1;
	}

	public int getPrevPage() {
		return prevPage;
	}

	public void setPrevPage(int prevPage) {
		this.prevPage = prevPage < 1 ? 1 : prevPage;
	}

	public int getNextPage() {
		return nextPage;
	}

	public void setNextPage(int nextPage) {
		this.nextPage = nextPage > this.totalPage ? this.totalPage : nextPage;
	}

	public int getTotalRec() {
		return totalRec;
	}

	public void setTotalRec(int totalRec) {
		this.totalRec = totalRec > -1 ? totalRec : 0;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize > 0 ? pageSize : defaultPageSize;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex > 0 ? pageIndex : 0;
	}

	public int[] getPageNumbers() {
		return pageNumbers;
	}

	public void setPageNumbers(int[] pageNumbers) {
		this.pageNumbers = pageNumbers;
	}

	public boolean isHasPrevPage() {
		return hasPrevPage;
	}

	public void setHasPrevPage(boolean hasPrevPage) {
		this.hasPrevPage = pageIndex > 1 ? hasPrevPage : false;
		//this.hasPrevPage = hasPrevPage;
	}

	public boolean isHasNextPage() {
		return hasNextPage;
	}

	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = pageIndex < totalPage ? hasNextPage : false;
		//this.hasNextPage = hasNextPage;
	}

	public boolean isHasPageInfo() {
		return hasPageInfo;
	}

	public void setHasPageInfo(boolean hasPageInfo) {
		this.hasPageInfo = totalRec>0?hasPageInfo:false;
	}
}
